<!DOCTYPE html>
<html>
<head>
	<meta charset='utf-8'>
	<title>表格可展开显示更多列-demo-完整版</title>
	<meta name='renderer' content='webkit'>
	<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
	<meta name='viewport'
				content='width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0'>
	<link rel='stylesheet' href='../../../layui/css/layui.css' media='all'>
	<style>
		body {
			padding: 40px;
		}

		.layui-card-header > span {
			font-weight: bold;
			font-size: 18px;
			color: #0C0C0C;
		}

		.open-new {
			font-size: 14px;
			border-bottom: #dedede solid 1px;
			margin-left: 80px;
		}
	</style>
</head>
<body>
<div class='layui-card'>
	<div class='layui-card-header'>
		<span>可展开表格Demo <span class="layui-badge layui-bg-green">简单版</span></span>
		<a href="index2.html" class="open-new">完整版</a></div>
	<div class='layui-card-body'>
		<table id='test' lay-filter='test'></table>
		<pre class='layui-code'></pre>

	</div>
</div>

<script type='text/html' id='barDemo'>
	<a class='layui-btn layui-btn-xs' lay-event='edit'>编辑</a>
	<a class='layui-btn layui-btn-danger layui-btn-xs' lay-event='del'>删除</a>
</script>
<script src='../../../layui/layui.js'></script>
<script id='demo-script'>


  //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 说明 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

  // 1、支持layui table 的所有参数

  // 2、扩展参数4个：
  // openCols:[]
  // sort:f
  // edit:f
  // openType
  // 详见完整版案例


  //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 使用案例  简单版↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

  layui.config({
    //配置 layui 第三方扩展组件存放的基础目录
    base: '../../../layui_exts/'
  }).extend({
    openTable: 'openTable/openTable'
  }).use(['openTable'], function () {
    var openTable = layui.openTable;
    openTable.render({
      elem: '#test'
      , id: '#test'
      , url: 'test.json'
      , cols: [[
        {field: 'id', title: 'ID', sort: true}
        , {field: 'username', title: '用户名', edit: true}
        , {field: 'city', title: '城市', edit: true}
        , {title: '操作', toolbar: '#barDemo', width: 150}
      ]]

      //注：展开的列Items
      , openCols: [
        {field: 'sign', title: '签名'}
        , {field: 'wealth', title: '财富'}
        , {field: 'experience', title: '积分'}
        , {field: 'classify', title: '职业'}
      ]

      //注：监听排序 {openTable}
      , sort: function (obj) {
        console.log(obj)
      }
      //注：0：同时只展开一项 1：一直展开不关闭之前  def：0 {openTable}
      , openType: 0

    });


    //注：更新样例代码格式化展示 实际开发可忽略不管
    setTimeout(function () {
      layui.$('.layui-code').text(layui.$('#demo-script').html())
    }, 20)
  });
</script>
</body>
</html>


